-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reconstructing query from dict not working #531
Conversation
Changes to be committed: modified: pydal/objects.py
¿any one? |
@@ -2172,14 +2172,15 @@ def build(self, d): | |||
d.get("second", None)) | |||
left = right = built = None | |||
|
|||
if op in ("AND", "OR"): | |||
op = op.upper() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand this fix. But why change AND -> _AND?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the query is pickle to the session the operators and, or and not are prefixed with _
, so: _AND
, _OR
and _NOT
In [1]: q = db(db.auth_user.id > 0) & (db.auth_user.id < 10)
In [2]: q
Out[2]: <Query (("auth_user"."id" < 10) AND <Set ("auth_user"."id" > 0)>)>
In [3]: q.as_dict()
Out[3]:
{'_db': <DAL uri="sqlite://storage.sqlite">,
'db': <DAL uri="sqlite://storage.sqlite">,
'first': <Query ("auth_user"."id" < 10)>,
'ignore_common_filters': False,
'op': <bound method SQLiteDialect._and of <pydal.dialects.sqlite.SQLiteDialect object at 0x7f897554ff90>>,
'optional_args': {},
'second': <Set ("auth_user"."id" > 0)>}
In [4]: q.as_dict(flat=True)
Out[4]:
{'first': {'first': {'fieldname': 'id', 'tablename': 'auth_user'},
'ignore_common_filters': False,
'op': 'lt',
'optional_args': {},
'second': 10},
'ignore_common_filters': False,
'op': '_and',
'optional_args': {}}
Note to that the <
is not prefixed with _
. Actually all the operatos are lowercase, i just make then upper there for the sake of not making to many changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I am slow I still do not understand where do the '_' comes from?
There is a problem in this, LTE ( |
3b526f9
to
2a77f13
Compare
This is a very old ticket and I was not able to understand or reproduce the problem. I am going to close it but I may very well be wrong. The example uses a syntax |
pydal/objects
for reconstructing aQuery
object from a dict.uploadfs.open
with expect aunicode
not astr
close #530